/* ================================
   绿波计算页面样式
   ================================ */

/* 背景渐变效果 */
.bg-dark-gradient {
    background: linear-gradient(135deg, #0f172a, #1e293b, #0f172a);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    min-height: 100vh;
    overflow-x: hidden; /* 防止水平滚动 */
    overflow-y: auto; /* 允许垂直滚动 */
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 主容器 */
.cal-container {
    padding: var(--space-xl);
    max-width: 1600px;
    margin: 0 auto;
    color: white;
    animation: fadeInUp 0.8s ease-out;
    margin-top: 80px; /* 给顶部导航留出空间 */
    min-height: calc(100vh - 80px); /* 确保页面可以滚动 */
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   页面标题区域
   ================================ */

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cal-title {
    flex: 1;
}

.cal-title i {
    font-size: 3rem;
    color: var(--accent-cyan);
    margin-right: var(--space-md);
    vertical-align: middle;
}

.cal-title h1 {
    display: inline-block;
    font-size: var(--font-3xl);
    font-weight: 700;
    color: var(--primary-green);
    margin: 0;
    vertical-align: middle;
}

.cal-title .subtitle {
    display: block;
    font-size: var(--font-lg);
    color: rgba(255, 255, 255, 0.7);
    margin-top: var(--space-sm);
    margin-left: 4.2rem;
}

/* 统计卡片区域 */
.cal-stats {
    display: flex;
    gap: var(--space-lg);
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 140px;
    transition: all var(--duration-normal) ease;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow-neon);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(76, 175, 80, 0.2);
    color: var(--primary-green);
    font-size: var(--font-xl);
}

.stat-icon.success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--text-success);
}

.stat-icon.info {
    background: rgba(33, 150, 243, 0.2);
    color: var(--accent-blue);
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: var(--font-xl);
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.7);
    margin-top: var(--space-xs);
}

/* ================================
   内容区域布局
   ================================ */

.cal-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: var(--space-2xl);
    align-items: start;
}

/* ================================
   左侧配置面板
   ================================ */

.config-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.config-section {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    animation: slideInLeft 0.6s ease-out;
}

.config-section:nth-child(1) { animation-delay: 0.1s; }
.config-section:nth-child(2) { animation-delay: 0.2s; }
.config-section:nth-child(3) { animation-delay: 0.3s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.section-header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--font-lg);
    font-weight: 600;
    color: white;
    margin: 0;
}

.section-title i {
    color: var(--primary-green);
}

/* ================================
   路口选择区域
   ================================ */

.selection-controls {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-sm);
}

.btn-secondary {
    background: rgba(156, 39, 176, 0.2);
    border: 1px solid rgba(156, 39, 176, 0.3);
    color: #e1bee7;
}

.btn-secondary:hover {
    background: rgba(156, 39, 176, 0.3);
    border-color: rgba(156, 39, 176, 0.5);
}

.selected-intersections {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.intersection-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--duration-normal) ease;
}

.intersection-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-green);
    transform: translateX(4px);
}

.intersection-item.active {
    background: rgba(76, 175, 80, 0.1);
    border-color: var(--primary-green);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.2);
}

.intersection-info {
    flex: 1;
}

.intersection-name {
    font-weight: 600;
    color: white;
    font-size: var(--font-base);
    margin-bottom: var(--space-xs);
}

.intersection-id,
.intersection-ctrl {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: var(--space-xs);
}

.intersection-id {
    font-family: 'Courier New', monospace;
}

.intersection-actions {
    display: flex;
    gap: var(--space-sm);
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all var(--duration-normal) ease;
}

.action-btn:hover {
    transform: scale(1.1);
}

.action-btn.config:hover {
    background: rgba(33, 150, 243, 0.3);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.action-btn.remove:hover {
    background: rgba(255, 23, 68, 0.3);
    border-color: var(--text-error);
    color: var(--text-error);
}

/* ================================
   参数配置区域
   ================================ */

.param-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.param-label {
    font-size: var(--font-sm);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--space-xs);
}

.param-input-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.param-input,
.param-select {
    flex: 1;
    background: rgba(29, 43, 64, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: white;
    font-size: var(--font-base);
    transition: all var(--duration-normal) ease;
}

.param-input:focus,
.param-select:focus {
    border-color: var(--primary-green);
    background: rgba(29, 43, 64, 0.8);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.param-unit {
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--font-sm);
    min-width: 40px;
}

/* ================================
   计算控制区域
   ================================ */

.calc-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.btn-large {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-lg);
    font-weight: 600;
}

.calc-progress {
    margin-top: var(--space-lg);
}

.progress-bar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    height: 8px;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green), var(--accent-cyan));
    border-radius: var(--radius-sm);
    transition: width var(--duration-normal) ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.progress-text {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
}

/* ================================
   右侧结果面板
   ================================ */

.result-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.result-section {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    animation: slideInRight 0.6s ease-out;
}

.result-section:nth-child(1) { animation-delay: 0.2s; }
.result-section:nth-child(2) { animation-delay: 0.4s; }

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-actions {
    display: flex;
    gap: var(--space-md);
}

/* ================================
   结果摘要卡片
   ================================ */

.result-summary {
    margin-bottom: var(--space-xl);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
}

.summary-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: all var(--duration-normal) ease;
}

.summary-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow-neon);
}

.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    font-size: var(--font-xl);
}

.card-icon.success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--text-success);
}

.card-icon.info {
    background: rgba(33, 150, 243, 0.2);
    color: var(--accent-blue);
}

.card-icon.warning {
    background: rgba(255, 152, 0, 0.2);
    color: var(--text-warning);
}

.card-content {
    flex: 1;
}

.card-value {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: white;
    line-height: 1.2;
    font-family: 'Courier New', monospace;
}

.card-label {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.7);
    margin-top: var(--space-xs);
}

/* ================================
   配时表格
   ================================ */

.timing-table-container {
    margin-top: var(--space-xl);
}

.table-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--font-lg);
    font-weight: 600;
    color: white;
    margin: 0 0 var(--space-lg) 0;
}

.table-title i {
    color: var(--primary-green);
}

.timing-table {
    background: rgba(29, 43, 64, 0.4);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-base);
    color: white;
}

.result-table thead th {
    background: rgba(29, 43, 64, 0.8);
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--accent-cyan);
    border-bottom: 2px solid var(--primary-green);
    font-size: var(--font-base);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.result-table tbody tr {
    transition: all var(--duration-normal) ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.result-table tbody tr:hover {
    background: rgba(76, 175, 80, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.1);
}

.result-table td {
    padding: var(--space-md);
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-base);
    vertical-align: middle;
}

.intersection-name {
    font-weight: 600;
    color: white;
}

.timing-value {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--accent-cyan);
    text-align: center;
}

.timing-value.highlight {
    color: var(--primary-green);
    background: rgba(76, 175, 80, 0.1);
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
}

.phase-indicator {
    text-align: center;
}

.phase-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 600;
}

.phase-badge.phase-1 {
    background: rgba(76, 175, 80, 0.2);
    color: var(--text-success);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.phase-badge.phase-2 {
    background: rgba(33, 150, 243, 0.2);
    color: var(--accent-blue);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.efficiency-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 120px;
}

.efficiency-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.efficiency-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green), var(--accent-cyan));
    border-radius: var(--radius-sm);
    transition: width var(--duration-normal) ease;
}

.efficiency-text {
    font-size: var(--font-sm);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    min-width: 35px;
    text-align: right;
}

/* ================================
   时空图区域
   ================================ */

.chart-controls {
    display: flex;
    gap: var(--space-md);
}

.chart-container {
    margin-top: var(--space-lg);
}

.chart-placeholder {
    position: relative;
    width: 100%;
    height: 400px;
    background: rgba(29, 43, 64, 0.4);
    border: 1px solid rgba(33, 150, 243, 0.2);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chart-bg {
    position: relative;
    width: 100%;
    height: 100%;
}

.chart-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, rgba(33, 150, 243, 0.1) 1px, transparent 1px),
        linear-gradient(0deg, rgba(33, 150, 243, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
}

.green-wave-bands {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.wave-band {
    position: absolute;
    height: 60px;
    background: linear-gradient(45deg, 
        rgba(76, 175, 80, 0.3), 
        rgba(76, 175, 80, 0.1), 
        rgba(76, 175, 80, 0.3));
    border: 1px solid rgba(76, 175, 80, 0.5);
    border-radius: var(--radius-sm);
    animation: waveFlow 4s ease-in-out infinite;
}

.wave-band.band-1 {
    top: 50px;
    left: 10%;
    width: 25%;
    animation-delay: 0s;
}

.wave-band.band-2 {
    top: 120px;
    left: 20%;
    width: 30%;
    animation-delay: 0.5s;
}

.wave-band.band-3 {
    top: 190px;
    left: 35%;
    width: 20%;
    animation-delay: 1s;
}

.wave-band.band-4 {
    top: 260px;
    left: 45%;
    width: 25%;
    animation-delay: 1.5s;
}

@keyframes waveFlow {
    0%, 100% { 
        opacity: 0.3;
        transform: scaleX(1);
    }
    50% { 
        opacity: 0.7;
        transform: scaleX(1.1);
    }
}

.intersection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.intersection-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 4px rgba(0, 229, 255, 0.5);
}

.intersection-line:nth-child(1) { top: 80px; }
.intersection-line:nth-child(2) { top: 150px; }
.intersection-line:nth-child(3) { top: 220px; }
.intersection-line:nth-child(4) { top: 290px; }

.intersection-line::before {
    content: attr(data-name);
    position: absolute;
    left: 10px;
    top: -20px;
    font-size: var(--font-sm);
    color: var(--accent-cyan);
    background: rgba(29, 43, 64, 0.8);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.chart-axes {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: rgba(29, 43, 64, 0.9);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
}

.axis-label {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.axis-ticks {
    display: flex;
    gap: var(--space-xl);
}

.axis-ticks span {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Courier New', monospace;
}

/* ================================
   响应式设计
   ================================ */

@media (max-width: 1200px) {
    .cal-container {
        padding: var(--space-lg);
    }
    
    .cal-header {
        flex-direction: column;
        gap: var(--space-lg);
        align-items: flex-start;
    }
    
    .cal-stats {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .cal-content {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
}

@media (max-width: 768px) {
    .cal-container {
        padding: var(--space-md);
    }
    
    .cal-stats {
        flex-direction: column;
    }
    
    .stat-card {
        min-width: unset;
    }
    
    .calc-controls {
        gap: var(--space-sm);
    }
    
    .result-table {
        font-size: var(--font-sm);
    }
    
    .chart-placeholder {
        height: 300px;
    }
    
    .intersection-line::before {
        font-size: var(--font-xs);
        padding: 2px var(--space-xs);
    }
}
